<template>
  <div>
    <Teleport to="body">
      <div v-if="open" class="modal">
        <p>{{ msg }}</p>
        <button @click="close" class="btn">点击关闭弹窗</button>
      </div>
    </Teleport>
  </div>
</template>

<script>
export default {
  props: {
    msg: {
      type: String,
      default: "not found",
    },
    open: {
      type: Boolean,
      default: false,
    },
  },
  setup(props, { emit }) {
    const close = () => {
      emit("close");
    };
    return {
      close,
    };
  },
};
</script>

<style scoped>
.modal {
  position: fixed;
  z-index: 999;
  top: 2%;
  left: 50%;
  width: 300px;
  margin-left: -150px;
  background: #54adfb;
  border-radius: 20px;
  color: white;
  text-align: center;
  padding: 20px;
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
}
.btn {
  display: block;
  font-size: 30px;
  color: #54adfb;
  background: white;
}
</style>